//
//  GNRViewController.m
//  GNRPickCard
//
//  Created by ly918@qq.com on 10/31/2017.
//  Copyright (c) 2017 ly918@qq.com. All rights reserved.
//

#import "GNRViewController.h"
#import "GNRCommonPicker.h"
#import "GNRSelectionBaseModel.h"
#import "GNRPaymentCollectionInputConfig.h"

@interface GNRViewController ()<GNRPickCardDelegate>
- (IBAction)showPressed:(id)sender;

@end

@implementation GNRViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)showPressed:(id)sender {
    
    GNRSelectionBaseModel *item = [GNRSelectionBaseModel new];
    item.title = @"不保价";
    item.subTitle = @"若商品出现损坏，最高可获得30元优惠券赔付";

    GNRSelectionBaseModel *item1 = [GNRSelectionBaseModel new];
    item1.title = @"投保3元";
    item1.subTitle = @"添加保价3元，最高可赔付×××元";

    GNRSelectionBaseModel *item2 = [GNRSelectionBaseModel new];
    item2.title = @"投保5元";
    item2.subTitle = @"添加保价5元，最高可赔付×××元";

    GNRCommonPicker *card = [GNRCommonPicker pickerForBaojiaWithItems:[NSMutableArray arrayWithArray:@[item,item1,item2]] selectItemBlock:^(GNRSelectionBaseModel *item, GNRPickCard *pickCard) {
        NSLog(@"selected item == %@",item);
    } actionBlock:^(id result, GNRCommonPicker *picker) {
        NSLog(@"action result == %@",[result title]);
    } footerPressedBlock:^(GNRBaojiaFooterView *baojiaFooter, GNRPickCard *pickCard) {
        NSLog(@"footerPressed == %@",baojiaFooter);
    }];

    card.showTitle = @"保价服务";
    card.closePressBlock = ^(GNRPickCard * _Nullable pickCard) {
        [pickCard dismissViewControllerAnimated:YES completion:nil];
    };
    
    [self showDetailViewController:card sender:nil];

}

- (IBAction)transportPressed:(id)sender {
    GNRSelectionBaseModel *item = [GNRSelectionBaseModel new];
    item.title = @"电动车配送";
    item.subTitle = @"选择后将为您安排电动车跑男提供服务";
    item.imageName = @"piickcard-transport-icon-dd";
    
    GNRSelectionBaseModel *item1 = [GNRSelectionBaseModel new];
    item1.title = @"大力神配送";
    item1.subTitle = @"选择后将为您安排大力神电动车跑男提供服务";
    item1.imageName = @"piickcard-transport-icon-dls";

    GNRSelectionBaseModel *item2 = [GNRSelectionBaseModel new];
    item2.title = @"面包车配送";
    item2.subTitle = @"选择后将为您安排面包车跑男提供服务";
    item2.imageName = @"piickcard-transport-icon-mb";

    GNRCommonPicker *card = [GNRCommonPicker pickerForTransportWithItems:[NSMutableArray arrayWithArray:@[item,item1,item2]] selectItemBlock:^(GNRSelectionBaseModel *item, GNRPickCard *pickCard) {
        NSLog(@"selected item == %@",item);
    } actionBlock:^(id result, GNRCommonPicker *picker) {
        NSLog(@"action result == %@",result);
    }];
    
    card.showTitle = @"配送工具服务";
    card.closePressBlock = ^(GNRPickCard * _Nullable pickCard) {
        [pickCard dismissViewControllerAnimated:YES completion:nil];
    };
    
    [self showDetailViewController:card sender:nil];
}

- (IBAction)goodsWeightPressed:(id)sender {
    GNRSelectionBaseModel *item = [GNRSelectionBaseModel new];
    item.title = @"5公斤以下";
    
    GNRSelectionBaseModel *item1 = [GNRSelectionBaseModel new];
    item1.title = @"5-10公斤";
    
    GNRSelectionBaseModel *item2 = [GNRSelectionBaseModel new];
    item2.title = @"10-15公斤";
    
    GNRSelectionBaseModel *item3 = [GNRSelectionBaseModel new];
    item3.title = @"15-25公斤";
    
    GNRSelectionBaseModel *item4 = [GNRSelectionBaseModel new];
    item4.title = @"25-50公斤";
    
    GNRCommonPicker *card = [GNRCommonPicker pickerForGoodsWeightWithItems:[NSMutableArray arrayWithArray:@[item,item1,item2,item3,item4]] selectItemBlock:^(GNRSelectionBaseModel *item, GNRPickCard *pickCard) {
        NSLog(@"selected item == %@",item);
    } actionBlock:^(id result, GNRCommonPicker *picker) {
        NSLog(@"action result == %@",result);
    }];
    
    card.showTitle = @"物品重量服务";
    card.closePressBlock = ^(GNRPickCard * _Nullable pickCard) {
        [pickCard dismissViewControllerAnimated:YES completion:nil];
    };
    
    [self showDetailViewController:card sender:nil];
}

- (IBAction)textInputPressed:(id)sender {
    GNRPaymentCollectionInputConfig *inputConfig = [GNRPaymentCollectionInputConfig new];
    
    GNRCommonPicker *card = [GNRCommonPicker pickerForInputConfig:inputConfig actionBlock:^(id result, GNRCommonPicker *picker) {
        NSLog(@"action result == %@",result);
    }];
    
    card.showTitle = @"代收货款服务";
    card.closePressBlock = ^(GNRPickCard * _Nullable pickCard) {
        [pickCard dismissViewControllerAnimated:YES completion:nil];
    };
    
    [self showDetailViewController:card sender:nil];
}



@end
